<?php
class Default_Model_menu extends Zend_Db_Table
{
	public function get_menu()
	{
	    $ns = new Zend_Session_Namespace('lang');
	    $lang=$ns->lang;
		$db = Zend_Registry::get('connectDb');
		$select = $db->select()
		          ->from('menu', array('id','title','type','keyt_id')) 
		          ->where('published = ?', '1')
		          ->where('language_id = ?',$lang)
		          ->where('position 	 = ?','1')
		          ->where('parents 	 = ?','0');
		$result = $db->fetchAll($select);
	    return $result;          
		
	}	
	
	public function get_about()
	{
	    $ns = new Zend_Session_Namespace('lang');
	    $lang=$ns->lang;
		$db = Zend_Registry::get('connectDb');
		$select = $db->select()
		          ->from('menu', array('id','title','type','keyt_id')) 
		          ->where('published = ?', '1')
		          ->where('language_id = ?',$lang)
		          ->where('position 	 = ?','1');
		$result = $db->fetchAll($select);
	    return $result;          
		
	}	
	
	public function get_child($id)
	{
	    $ns = new Zend_Session_Namespace('lang');
	    $lang=$ns->lang;
		$db = Zend_Registry::get('connectDb');
		$select = $db->select()
		          ->from('menu', array('id','title','type','keyt_id')) 
		          ->where('published = ?', '1')
		          ->where('language_id = ?',$lang)
		          ->where('parents 	 = ?',$id);
		$result = $db->fetchAll($select);
	    return $result;          
		
	}	
	
	public function get_link($id,$type,$title,$key_id)
	{
	    if ($type==1)
	       {
			 $link=JURI;	
		   }
		elseif ($type==2)
		   {
		    $link=JURI.'index/about/title/'.$title.'/id/'.$key_id;
		    }
	    elseif ($type==3)
		   {
		    $link=JURI.'index/product/title/'.$title.'/id/'.$key_id;
		    }
	    elseif ($type==7)
		   {
		    $link=JURI.'index/category/title/'.$title.'/id/'.$key_id;
		    }
		  
		
	     return $link;
	}	
}